<include file="Public:head" />
<style>
    tr td{
        text-align: center;
    }
    .dannum{
        width: 300px;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        display: inline-block;
    }
</style>
<body class="overflow-hidden">
<div class="wrapper preload">
    <include file="Public:header" />
    <include file="Public:left" />

    <div class="main-container">
        <div class="padding-md">
            <div class="row">
                <div class="col-sm-12">
                    <div class="page-title">
                        导出数据库
                    </div>
                </div>
            </div>
            <div class="col-sm-12 row chach">
            </div>
            <div class="row">
                <div class="col-lg-12">
                    <div class="smart-widget widget-green">
                        <div class="smart-widget-header row ">
                            <span class="smart-widget-option">
                                <span class="refresh-icon-animated">
                                    <i class="fa fa-spinner fa-spin" style="color:#fff"></i>
                                </span>
                                <a href="#" class="widget-toggle-hidden-option">
                                </a>
                                <a href="#" class="widget-collapse-option" data-toggle="collapse">
                                </a>
                                <a href="#" class="widget-refresh-option">
                                </a>
                            </span>
                        </div>
                        <div class="smart-widget-inner table-responsive">
                            <div class="smart-widget-hidden-section">
                                <ul class="widget-color-list clearfix">
                                    <li style="background-color:#20232b;" data-color="widget-dark"></li>
                                    <li style="background-color:#4c5f70;" data-color="widget-dark-blue"></li>
                                    <li style="background-color:#23b7e5;" data-color="widget-blue"></li>
                                    <li style="background-color:#1fb5ac;" data-color="widget-green"></li>
                                    <li style="background-color:#edbc6c;" data-color="widget-yellow"></li>
                                    <li style="background-color:#fbc852;" data-color="widget-orange"></li>
                                    <li style="background-color:#e36159;" data-color="widget-red"></li>
                                    <li style="background-color:#7266ba;" data-color="widget-purple"></li>
                                    <li style="background-color:#f5f5f5;" data-color="widget-light-grey"></li>
                                    <li style="background-color:#fff;" data-color="reset"></li>
                                </ul>
                            </div>
                            <form id="export-form" method="post" action="{:U('export')}">
                            <table class="table table-striped no-margin">
                                <thead>
                                <tr>
                                    <th class="text-center" style="width: 5%">序号</th>
                                    <th class="text-center " >备份名称</th>
                                    <th class="text-center" style="width: 5%">卷数</th>
                                    <th class="text-center" style="width: 10%">压缩</th>
                                    <th class="text-center" style="width: 10%">数据大小</th>
                                    <th class="text-center" style="width: 20%">备份时间</th>
                                    <th class="text-center" style="width: 5%">状态</th>
                                    <th class="text-center" style="width: 20%">操作</th>

                                </tr>
                                </thead>
                                <tbody>
                                <notempty name="list">
                                    <volist name="list" id="data" key="k">
                                        <tr>
                                            <td>{$k}</td>
                                            <td>{$data.time|date='Ymd-His',###}</td>
                                            <td>{$data.part}</td>
                                            <td>{$data.compress}</td>
                                            <td>{$data.size|format_bytes}</td>
                                            <td>{$key}</td>
                                            <td>-</td>
                                            <td class="action">
                                                <a class="db-import" href="{:U('import?time='.$data['time'])}">还原</a>&nbsp;
                                                <a class="ajax-get confirm" href="{:U('del?time='.$data['time'])}">删除</a>
                                            </td>
                                        </tr>
                                    </volist>
                                    <else/>
                                    <td colspan="10" class="text-center"> aOh! 暂时还没有内容! </td>
                                </notempty>
                                </tbody>
                            </table>
                            </form>
                            <div class="choose-page row">
                                {$_page}
                            </div>
                        </div><!-- ./smart-widget-inner -->
                    </div><!-- ./smart-widget -->
                </div><!-- ./col -->
            </div><!-- ./row -->
        </div><!-- ./padding-md -->
    </div><!-- /main-container -->
    <include file="Public:foot" />
</div><!-- /wrapper -->
<a href="#" class="scroll-to-top hidden-print"><i class="fa fa-chevron-up fa-lg"></i></a>
</body>
</html>
<block name="script">
    <script>
        $(".db-import").click(function(){
            var self = this, status = ".";
            $.get(self.href, success, "json");
            window.onbeforeunload = function(){ return "正在还原数据库，请不要关闭！" }
            return false;

            function success(data){
                if(data.status){
                    if(data.gz){
                        data.info += status;
                        if(status.length === 5){
                            status = ".";
                        } else {
                            status += ".";
                        }
                    }
                    $(self).parent().prev().text(data.info);
                    if(data.part){
                        $.get(self.href,
                                {"part" : data.part, "start" : data.start},
                                success,
                                "json"
                        );
                    }  else {
                        window.onbeforeunload = function(){ return null; }
                    }
                } else {
                    updateAlert(data.info,'alert-error');
                }
            }
        });
        $(function(){
            highlight_nav2('__SELF__');
        })


    </script>
</block>
